package main;

import com.nokia.mid.ui.gestures.GestureEvent;
import com.nokia.mid.ui.gestures.GestureInteractiveZone;
import com.nokia.mid.ui.gestures.GestureListener;

//Listens for gesture events and sends them at the main canvas
public class GestureHandler implements GestureListener
{
    public void gestureAction(Object container, 
                              GestureInteractiveZone gestureInteractiveZone,
                              GestureEvent gestureEvent)
    {
        switch (gestureEvent.getType())
        {
            case GestureInteractiveZone.GESTURE_DRAG:
                //System.out.println("drag");
                break;
                
            case GestureInteractiveZone.GESTURE_DROP:
                //System.out.println("drop");
                break;
                
            case GestureInteractiveZone.GESTURE_FLICK:
                System.out.println("flick");
                try
                {
                    int x = gestureEvent.getStartX();
                    int y = gestureEvent.getStartY();
                    ((MainCanvas)container).receivedFlick(x, y);
                }
                catch (IllegalStateException e)
                {
                    System.err.println(e);
                }
                break;
            
            case GestureInteractiveZone.GESTURE_LONG_PRESS:
                System.out.println("long press");
                try
                {
                    int x = gestureEvent.getStartX();
                    int y = gestureEvent.getStartY();
                    ((MainCanvas)container).receivedLongPress(x, y);
                }
                catch (IllegalStateException e)
                {
                    System.err.println(e);
                }
                break;
            
            case GestureInteractiveZone.GESTURE_LONG_PRESS_REPEATED:
                //System.out.println("long press repeated");
                break;
            
            case GestureInteractiveZone.GESTURE_TAP:
                System.out.println("tap");
                try
                {
                    int x = gestureEvent.getStartX();
                    int y = gestureEvent.getStartY();
                    ((MainCanvas)container).receivedTAP(x, y);
                }
                catch (IllegalStateException e)
                {
                    System.err.println(e);
                }
                break;
        }
    }
}